package com.yanqu.road.server.timer;

import com.yanqu.road.server.manager.union.CrossUnionJoinApplyMgr;
import com.yanqu.road.server.manger.ServerListMgr;
import com.yanqu.road.utils.date.DateHelper;
import com.yanqu.road.utils.executor.GeneralTask;

public class CrossServerListMgrReloadTask extends GeneralTask {

    private int lastCheckTime = DateHelper.getCurrentSecond();

    @Override
    public void doRun() {

        try {
            if(DateHelper.getCurrentSecond() - lastCheckTime >= DateHelper.MINUTE_SECONDS * 5) {
                ServerListMgr.reloadServerList();
                lastCheckTime = DateHelper.getCurrentSecond();
            }
            new CrossUnionJoinApplyMgr().reloadConfig();
        } catch (Exception e) {
            getLOGGER().error(e.getMessage(), e);
        }

    }
}
